home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / libgimp / gimpchannel_pdb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-12-27  |  13.1 KB  |  552 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimpchannel_pdb.c
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  */
  21.  
  22. /* NOTE: This file is autogenerated by pdbgen.pl */
  23.  
  24. #include "gimp.h"
  25.  
  26. /**
  27.  * _gimp_channel_new:
  28.  * @image_ID: The image to which to add the channel.
  29.  * @width: The channel width.
  30.  * @height: The channel height.
  31.  * @name: The channel name.
  32.  * @opacity: The channel opacity.
  33.  * @red:
  34.  * @green:
  35.  * @blue: The channel compositing color.
  36.  *
  37.  * Create a new channel.
  38.  *
  39.  * This procedure creates a new channel with the specified width and
  40.  * height. Name, opacity, and color are also supplied parameters. The
  41.  * new channel still needs to be added to the image, as this is not
  42.  * automatic. Add the new channel with the 'gimp_image_add_channel'
  43.  * command. Other attributes such as channel show masked, should be set
  44.  * with explicit procedure calls. The channel's contents are undefined
  45.  * initially.
  46.  *
  47.  * Returns: The newly created channel.
  48.  */
  49. gint32
  50. _gimp_channel_new (gint32   image_ID,
  51.            gint     width,
  52.            gint     height,
  53.            gchar   *name,
  54.            gdouble  opacity,
  55.            guchar   red,
  56.            guchar   green,
  57.            guchar   blue)
  58. {
  59.   GimpParam *return_vals;
  60.   gint nreturn_vals;
  61.   gint32 channel_ID = -1;
  62.   guchar color[3];
  63.  
  64.   color[0] = red;
  65.   color[1] = green;
  66.   color[2] = blue;
  67.  
  68.   return_vals = gimp_run_procedure ("gimp_channel_new",
  69.                     &nreturn_vals,
  70.                     GIMP_PDB_IMAGE, image_ID,
  71.                     GIMP_PDB_INT32, width,
  72.                     GIMP_PDB_INT32, height,
  73.                     GIMP_PDB_STRING, name,
  74.                     GIMP_PDB_FLOAT, opacity,
  75.                     GIMP_PDB_COLOR, color,
  76.                     GIMP_PDB_END);
  77.  
  78.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  79.     channel_ID = return_vals[1].data.d_channel;
  80.  
  81.   gimp_destroy_params (return_vals, nreturn_vals);
  82.  
  83.   return channel_ID;
  84. }
  85.  
  86. /**
  87.  * gimp_channel_copy:
  88.  * @channel_ID: The channel to copy.
  89.  *
  90.  * Copy a channel.
  91.  *
  92.  * This procedure copies the specified channel and returns the copy.
  93.  *
  94.  * Returns: The newly copied channel.
  95.  */
  96. gint32
  97. gimp_channel_copy (gint32 channel_ID)
  98. {
  99.   GimpParam *return_vals;
  100.   gint nreturn_vals;
  101.   gint32 channel_copy_ID = -1;
  102.  
  103.   return_vals = gimp_run_procedure ("gimp_channel_copy",
  104.                     &nreturn_vals,
  105.                     GIMP_PDB_CHANNEL, channel_ID,
  106.                     GIMP_PDB_END);
  107.  
  108.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  109.     channel_copy_ID = return_vals[1].data.d_channel;
  110.  
  111.   gimp_destroy_params (return_vals, nreturn_vals);
  112.  
  113.   return channel_copy_ID;
  114. }
  115.  
  116. /**
  117.  * gimp_channel_delete:
  118.  * @channel_ID: The channel to delete.
  119.  *
  120.  * Delete a channel.
  121.  *
  122.  * This procedure deletes the specified channel. This must not be done
  123.  * if the gimage containing this channel was already deleted or if the
  124.  * channel was already removed from the image. The only case in which
  125.  * this procedure is useful is if you want to get rid of a channel
  126.  * which has not yet been added to an image.
  127.  *
  128.  * Returns: TRUE on success.
  129.  */
  130. gboolean
  131. gimp_channel_delete (gint32 channel_ID)
  132. {
  133.   GimpParam *return_vals;
  134.   gint nreturn_vals;
  135.   gboolean success = TRUE;
  136.  
  137.   return_vals = gimp_run_procedure ("gimp_channel_delete",
  138.                     &nreturn_vals,
  139.                     GIMP_PDB_CHANNEL, channel_ID,
  140.                     GIMP_PDB_END);
  141.  
  142.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  143.  
  144.   gimp_destroy_params (return_vals, nreturn_vals);
  145.  
  146.   return success;
  147. }
  148.  
  149. /**
  150.  * gimp_channel_get_name:
  151.  * @channel_ID: The channel.
  152.  *
  153.  * Get the name of the specified channel.
  154.  *
  155.  * This procedure returns the specified channel's name.
  156.  *
  157.  * Returns: The channel name.
  158.  */
  159. gchar *
  160. gimp_channel_get_name (gint32 channel_ID)
  161. {
  162.   GimpParam *return_vals;
  163.   gint nreturn_vals;
  164.   gchar *name = NULL;
  165.  
  166.   return_vals = gimp_run_procedure ("gimp_channel_get_name",
  167.                     &nreturn_vals,
  168.                     GIMP_PDB_CHANNEL, channel_ID,
  169.                     GIMP_PDB_END);
  170.  
  171.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  172.     name = g_strdup (return_vals[1].data.d_string);
  173.  
  174.   gimp_destroy_params (return_vals, nreturn_vals);
  175.  
  176.   return name;
  177. }
  178.  
  179. /**
  180.  * gimp_channel_set_name:
  181.  * @channel_ID: The channel.
  182.  * @name: The new channel name.
  183.  *
  184.  * Set the name of the specified channel.
  185.  *
  186.  * This procedure sets the specified channel's name.
  187.  *
  188.  * Returns: TRUE on success.
  189.  */
  190. gboolean
  191. gimp_channel_set_name (gint32  channel_ID,
  192.                gchar  *name)
  193. {
  194.   GimpParam *return_vals;
  195.   gint nreturn_vals;
  196.   gboolean success = TRUE;
  197.  
  198.   return_vals = gimp_run_procedure ("gimp_channel_set_name",
  199.                     &nreturn_vals,
  200.                     GIMP_PDB_CHANNEL, channel_ID,
  201.                     GIMP_PDB_STRING, name,
  202.                     GIMP_PDB_END);
  203.  
  204.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  205.  
  206.   gimp_destroy_params (return_vals, nreturn_vals);
  207.  
  208.   return success;
  209. }
  210.  
  211. /**
  212.  * gimp_channel_get_visible:
  213.  * @channel_ID: The channel.
  214.  *
  215.  * Get the visibility of the specified channel.
  216.  *
  217.  * This procedure returns the specified channel's visibility.
  218.  *
  219.  * Returns: The channel visibility.
  220.  */
  221. gboolean
  222. gimp_channel_get_visible (gint32 channel_ID)
  223. {
  224.   GimpParam *return_vals;
  225.   gint nreturn_vals;
  226.   gboolean visible = FALSE;
  227.  
  228.   return_vals = gimp_run_procedure ("gimp_channel_get_visible",
  229.                     &nreturn_vals,
  230.                     GIMP_PDB_CHANNEL, channel_ID,
  231.                     GIMP_PDB_END);
  232.  
  233.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  234.     visible = return_vals[1].data.d_int32;
  235.  
  236.   gimp_destroy_params (return_vals, nreturn_vals);
  237.  
  238.   return visible;
  239. }
  240.  
  241. /**
  242.  * gimp_channel_set_visible:
  243.  * @channel_ID: The channel.
  244.  * @visible: The new channel visibility.
  245.  *
  246.  * Set the visibility of the specified channel.
  247.  *
  248.  * This procedure sets the specified channel's visibility.
  249.  *
  250.  * Returns: TRUE on success.
  251.  */
  252. gboolean
  253. gimp_channel_set_visible (gint32   channel_ID,
  254.               gboolean visible)
  255. {
  256.   GimpParam *return_vals;
  257.   gint nreturn_vals;
  258.   gboolean success = TRUE;
  259.  
  260.   return_vals = gimp_run_procedure ("gimp_channel_set_visible",
  261.                     &nreturn_vals,
  262.                     GIMP_PDB_CHANNEL, channel_ID,
  263.                     GIMP_PDB_INT32, visible,
  264.                     GIMP_PDB_END);
  265.  
  266.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  267.  
  268.   gimp_destroy_params (return_vals, nreturn_vals);
  269.  
  270.   return success;
  271. }
  272.  
  273. /**
  274.  * gimp_channel_get_show_masked:
  275.  * @channel_ID: The channel.
  276.  *
  277.  * Get the composite method of the specified channel.
  278.  *
  279.  * This procedure returns the specified channel's composite method. If
  280.  * it is non-zero, then the channel is composited with the image so
  281.  * that masked regions are shown. Otherwise, selected regions are
  282.  * shown.
  283.  *
  284.  * Returns: The channel composite method.
  285.  */
  286. gboolean
  287. gimp_channel_get_show_masked (gint32 channel_ID)
  288. {
  289.   GimpParam *return_vals;
  290.   gint nreturn_vals;
  291.   gboolean show_masked = FALSE;
  292.  
  293.   return_vals = gimp_run_procedure ("gimp_channel_get_show_masked",
  294.                     &nreturn_vals,
  295.                     GIMP_PDB_CHANNEL, channel_ID,
  296.                     GIMP_PDB_END);
  297.  
  298.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  299.     show_masked = return_vals[1].data.d_int32;
  300.  
  301.   gimp_destroy_params (return_vals, nreturn_vals);
  302.  
  303.   return show_masked;
  304. }
  305.  
  306. /**
  307.  * gimp_channel_set_show_masked:
  308.  * @channel_ID: The channel.
  309.  * @show_masked: The new channel composite method.
  310.  *
  311.  * Set the composite method of the specified channel.
  312.  *
  313.  * This procedure sets the specified channel's composite method. If it
  314.  * is non-zero, then the channel is composited with the image so that
  315.  * masked regions are shown. Otherwise, selected regions are shown.
  316.  *
  317.  * Returns: TRUE on success.
  318.  */
  319. gboolean
  320. gimp_channel_set_show_masked (gint32   channel_ID,
  321.                   gboolean show_masked)
  322. {
  323.   GimpParam *return_vals;
  324.   gint nreturn_vals;
  325.   gboolean success = TRUE;
  326.  
  327.   return_vals = gimp_run_procedure ("gimp_channel_set_show_masked",
  328.                     &nreturn_vals,
  329.                     GIMP_PDB_CHANNEL, channel_ID,
  330.                     GIMP_PDB_INT32, show_masked,
  331.                     GIMP_PDB_END);
  332.  
  333.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  334.  
  335.   gimp_destroy_params (return_vals, nreturn_vals);
  336.  
  337.   return success;
  338. }
  339.  
  340. /**
  341.  * gimp_channel_get_opacity:
  342.  * @channel_ID: The channel.
  343.  *
  344.  * Get the opacity of the specified channel.
  345.  *
  346.  * This procedure returns the specified channel's opacity.
  347.  *
  348.  * Returns: The channel opacity.
  349.  */
  350. gdouble
  351. gimp_channel_get_opacity (gint32 channel_ID)
  352. {
  353.   GimpParam *return_vals;
  354.   gint nreturn_vals;
  355.   gdouble opacity = 0;
  356.  
  357.   return_vals = gimp_run_procedure ("gimp_channel_get_opacity",
  358.                     &nreturn_vals,
  359.                     GIMP_PDB_CHANNEL, channel_ID,
  360.                     GIMP_PDB_END);
  361.  
  362.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  363.     opacity = return_vals[1].data.d_float;
  364.  
  365.   gimp_destroy_params (return_vals, nreturn_vals);
  366.  
  367.   return opacity;
  368. }
  369.  
  370. /**
  371.  * gimp_channel_set_opacity:
  372.  * @channel_ID: The channel.
  373.  * @opacity: The new channel opacity.
  374.  *
  375.  * Set the opacity of the specified channel.
  376.  *
  377.  * This procedure sets the specified channel's opacity.
  378.  *
  379.  * Returns: TRUE on success.
  380.  */
  381. gboolean
  382. gimp_channel_set_opacity (gint32  channel_ID,
  383.               gdouble opacity)
  384. {
  385.   GimpParam *return_vals;
  386.   gint nreturn_vals;
  387.   gboolean success = TRUE;
  388.  
  389.   return_vals = gimp_run_procedure ("gimp_channel_set_opacity",
  390.                     &nreturn_vals,
  391.                     GIMP_PDB_CHANNEL, channel_ID,
  392.                     GIMP_PDB_FLOAT, opacity,
  393.                     GIMP_PDB_END);
  394.  
  395.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  396.  
  397.   gimp_destroy_params (return_vals, nreturn_vals);
  398.  
  399.   return success;
  400. }
  401.  
  402. /**
  403.  * gimp_channel_get_color:
  404.  * @channel_ID: The channel.
  405.  * @red:
  406.  * @green:
  407.  * @blue: The channel compositing color.
  408.  *
  409.  * Get the compositing color of the specified channel.
  410.  *
  411.  * This procedure returns the specified channel's compositing color.
  412.  *
  413.  * Returns: TRUE on success.
  414.  */
  415. gboolean
  416. gimp_channel_get_color (gint32  channel_ID,
  417.             guchar *red,
  418.             guchar *green,
  419.             guchar *blue)
  420. {
  421.   GimpParam *return_vals;
  422.   gint nreturn_vals;
  423.   gboolean success = TRUE;
  424.  
  425.   return_vals = gimp_run_procedure ("gimp_channel_get_color",
  426.                     &nreturn_vals,
  427.                     GIMP_PDB_CHANNEL, channel_ID,
  428.                     GIMP_PDB_END);
  429.  
  430.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  431.  
  432.   if (success)
  433.     {
  434.       *red = return_vals[1].data.d_color.red;
  435.       *green = return_vals[1].data.d_color.green;
  436.       *blue = return_vals[1].data.d_color.blue;
  437.     }
  438.  
  439.   gimp_destroy_params (return_vals, nreturn_vals);
  440.  
  441.   return success;
  442. }
  443.  
  444. /**
  445.  * gimp_channel_set_color:
  446.  * @channel_ID: The channel.
  447.  * @red:
  448.  * @green:
  449.  * @blue: The new channel compositing color.
  450.  *
  451.  * Set the compositing color of the specified channel.
  452.  *
  453.  * This procedure sets the specified channel's compositing color.
  454.  *
  455.  * Returns: TRUE on success.
  456.  */
  457. gboolean
  458. gimp_channel_set_color (gint32 channel_ID,
  459.             guchar red,
  460.             guchar green,
  461.             guchar blue)
  462. {
  463.   GimpParam *return_vals;
  464.   gint nreturn_vals;
  465.   gboolean success = TRUE;
  466.   guchar color[3];
  467.  
  468.   color[0] = red;
  469.   color[1] = green;
  470.   color[2] = blue;
  471.  
  472.   return_vals = gimp_run_procedure ("gimp_channel_set_color",
  473.                     &nreturn_vals,
  474.                     GIMP_PDB_CHANNEL, channel_ID,
  475.                     GIMP_PDB_COLOR, color,
  476.                     GIMP_PDB_END);
  477.  
  478.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  479.  
  480.   gimp_destroy_params (return_vals, nreturn_vals);
  481.  
  482.   return success;
  483. }
  484.  
  485. /**
  486.  * gimp_channel_get_tattoo:
  487.  * @channel_ID: The channel.
  488.  *
  489.  * Get the tattoo of the specified channel.
  490.  *
  491.  * This procedure returns the specified channel's tattoo. A tattoo is a
  492.  * unique and permanent identifier attached to a channel that can be
  493.  * used to uniquely identify a channel within an image even between
  494.  * sessions.
  495.  *
  496.  * Returns: The channel tattoo.
  497.  */
  498. gint
  499. gimp_channel_get_tattoo (gint32 channel_ID)
  500. {
  501.   GimpParam *return_vals;
  502.   gint nreturn_vals;
  503.   gint tattoo = 0;
  504.  
  505.   return_vals = gimp_run_procedure ("gimp_channel_get_tattoo",
  506.                     &nreturn_vals,
  507.                     GIMP_PDB_CHANNEL, channel_ID,
  508.                     GIMP_PDB_END);
  509.  
  510.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  511.     tattoo = return_vals[1].data.d_tattoo;
  512.  
  513.   gimp_destroy_params (return_vals, nreturn_vals);
  514.  
  515.   return tattoo;
  516. }
  517.  
  518. /**
  519.  * gimp_channel_set_tattoo:
  520.  * @channel_ID: The channel.
  521.  * @tattoo: The new channel tattoo.
  522.  *
  523.  * Set the tattoo of the specified channel.
  524.  *
  525.  * This procedure sets the specified channel's tattoo. A tattoo is a
  526.  * unique and permanent identifier attached to a channel that can be
  527.  * used to uniquely identify a channel within an image even between
  528.  * sessions.
  529.  *
  530.  * Returns: TRUE on success.
  531.  */
  532. gboolean
  533. gimp_channel_set_tattoo (gint32 channel_ID,
  534.              gint   tattoo)
  535. {
  536.   GimpParam *return_vals;
  537.   gint nreturn_vals;
  538.   gboolean success = TRUE;
  539.  
  540.   return_vals = gimp_run_procedure ("gimp_channel_set_tattoo",
  541.                     &nreturn_vals,
  542.                     GIMP_PDB_CHANNEL, channel_ID,
  543.                     GIMP_PDB_INT32, tattoo,
  544.                     GIMP_PDB_END);
  545.  
  546.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  547.  
  548.   gimp_destroy_params (return_vals, nreturn_vals);
  549.  
  550.   return success;
  551. }
  552.